﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;

namespace FizzDevelop
{
	public partial class NewProjectDialog : Form
	{
		public NewProjectDialog()
		{
			InitializeComponent();
		}

		public DialogResult ShowDialog(out string name, out string path)
		{
			DialogResult result = base.ShowDialog();
			name = "";
			path = "";
		TryAgain:
			if (result == System.Windows.Forms.DialogResult.OK)
			{
				name = NameTextbox.Text;
				if (String.IsNullOrWhiteSpace(name))
				{
					MessageBox.Show("Please choose a project name.");
					result = base.ShowDialog();
					goto TryAgain;
				}
				path = LocationTextbox.Text;
				if (String.IsNullOrWhiteSpace(path))
				{
					MessageBox.Show("Please choose a project folder.");
					result = base.ShowDialog();
					goto TryAgain;
				}
			}
			return result;
		}

		private void BrowseButton_Click(object sender, EventArgs e)
		{
			string path = Util.GetFolder("Choose a folder...");
			if (!String.IsNullOrEmpty(path)) LocationTextbox.Text = path;
		}
	}
}